#include "graph.h"

void Graph::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{

   // painter->setBrush(Qt::black);

    foreach(Node* n, m_nodes)
    {
        painter->setPen(QPen(Qt::black));
        painter->drawEllipse(n->getPos().x()-1,n->getPos().y()-1,2,2);
        foreach(Edge* e, n->edges)
        {
          painter->setPen(QPen(Qt::gray));
          painter->drawLine(e->getFrom()->getPos(),e->getTo()->getPos());
        }
    }

}



void Graph::addNode(Node* n)
{
    if(n->getIndex()>=m_nodes.size())
    {
        m_nodes.push_back(n);
    }
}

QRectF Graph::boundingRect() const
{
    return m_boundingRect;
}

void Graph::setBoundingRect(QRectF rect)
{
    m_boundingRect=rect;
}
